<template>
  <div class="common-layout">
    <el-container>
      <el-header>
        <el-row :gutter="20">
          <el-col :span="4">
            <img src="../assets/logo.png" />
          </el-col>
          <el-col :span="16"> <h1>(vue3+typescript)后台管理系统</h1> </el-col>
          <el-col :span="4"> 退出登录 </el-col>
        </el-row>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <!--侧边栏编写-->
          <el-menu
            active-text-color="#ffd04b"
            background-color="#545c64"
            class="el-menu-vertical-demo"
            default-active="1"
            text-color="#fff"
            router
          >
            <!--router开启路由模式, 通过el-menu-item中的index来进行跳转-->
            <el-menu-item :index="item.path" v-for="item in list" :key="item.path">
              <span>{{item.meta.title}}</span>
            </el-menu-item>    
          </el-menu>
        </el-aside>
        <el-main>
            <!--设置路由出口-->
            <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang="ts">
import {defineComponent} from "vue";
import {useRouter} from "vue-router";
export default defineComponent({
  name: "HomeView",
  setup() {
    const router = useRouter();
    const list = router.getRoutes().filter(v=>v.meta.isShow)
    return {
        list
    }
  },
  components: {}
});
</script>

<style lang="scss" scoped>
.el-header {
  height: 40px;
  line-height: 40px;
  text-align: center;
  background: #666;
  color: #fff;
  font-size: 10px;
  img {
    height: 40px;
  }
}

.el-menu{
    height: calc(100vh - 40px);
}
</style>